#define _CRT_SECURE_NO_WARNINGS 1
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 1510;
int h[N], e[N], ne[N], idx;
int f[N][2];
bool st[N];
int n, ans;
void add(int a, int b)
{
    e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void dfs(int u)
{
    f[u][0] = 0;
    f[u][1] = 1;
    for (int i = h[u]; ~i; i = ne[i])
    {
        int j = e[i];
        dfs(j);
        f[u][1] += min(f[j][1], f[j][0]);
        f[u][0] += f[j][1];
    }
}
int main()
{
    while (scanf("%d", &n) != EOF)
    {
        memset(h, -1, sizeof h);
        memset(st, false, sizeof st);
        idx = 0;
        for (int i = 0; i < n; i++)
        {
            int a, b, cnt = 0;
            scanf("%d:(%d)", &a, &cnt);
            while (cnt--)
            {
                scanf("%d", &b);
                add(a, b);
                st[b] = true;
            }
        }
        int root = 0;
        while (st[root]) root++;
        dfs(root);
        printf("%d\n", min(f[root][0], f[root][1]));
    }
    return 0;
}